package com.toilet.easyvideofx.service.impl;

import com.toilet.easyvideofx.domain.Sysconfig;
import com.toilet.easyvideofx.mapper.SysConfigMapper;
import com.toilet.easyvideofx.service.SysConfigService;
import com.toilet.easyvideofx.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

public class SysConfigServiceImpl implements SysConfigService {
    @Override
    public Sysconfig selectByTag(String tag) {
        try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
            SysConfigMapper mapper = sqlSession.getMapper(SysConfigMapper.class);
            return mapper.selectByTag(tag);
        } catch (Exception e) {
            System.out.println("查询异常:" + e);
        }
        return null;
    }

    @Override
    public int updateByTag(String tag, Sysconfig sysconfig) {
        try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
            SysConfigMapper mapper = sqlSession.getMapper(SysConfigMapper.class);
            int row = mapper.updateByTag(tag, sysconfig);
            sqlSession.commit();
            return row;
        } catch (Exception e) {
            System.out.println("查询异常:" + e);
        }
        return 0;
    }
}
